#include "GUI.h"
#include "IElement.h"
#pragma once

typedef void     (*INITEBOOK)(HWND,RECT);
typedef bool     (*OPENEBOOK)(TCHAR*);
typedef TCHAR*	  (*GETLASTEBOOK)();
typedef void     (*DRAWPAGETEXT)(HDC hDc);
typedef void	  (*MOVE)(int,int);
typedef void     (*GETFONTINFO)(int&,BOOL&,TCHAR*,int&);
typedef void     (*SETFONTINFO)(int,BOOL,TCHAR*,int);
typedef void     (*SETCOLORINFO)(COLORREF,COLORREF,COLORREF);
typedef void     (*GETCOLORINFO)(COLORREF&,COLORREF&,COLORREF&);
typedef TCHAR*	  (*GETCURSELTEXT)();
typedef void     (*ADDBOOKMARK)();
typedef void     (*BUTTONDOWN)(POINT);
typedef void     (*BUTTONUP)(POINT);
typedef void     (*MOUSEMOVE)(POINT);
typedef void     (*SETFULLSCREEN)();
typedef int      (*GETLISTBMCOUNT)();
typedef void     (*GETBMTEXT)(int,TCHAR* ,int&);
typedef void     (*GOTOPOS)(int);
typedef void     (*DELBOOKMARK)(int);
typedef void     (*SETPERCENT)(int);
typedef int      (*GETPERCENT)();
typedef void     (*EBOOKDONE)();

enum {
	mLine=1,
	mPage=2,
	mFile=3,

	mFwd=0,
	mBack=1
};


class  GUI_API CEbook :public IElement
{
public:
	CEbook(void);
	virtual ~CEbook(void);
	bool m_bEnble;
	virtual void acceptVisitor(IVisitor ** visitor);
public:
	CEbook(const WCHAR * szBmpName,RECT rct,const WCHAR * name);
	virtual void draw(HDC * hdc);
	virtual void setEnble(bool bEnble){m_bEnble=bEnble;}
public:
	BOOL Init(wstring strDllPath);

	void     InitEBook(HWND hWnd);
	bool     OpenEBook(TCHAR* strFilePath);
	TCHAR*   GetLastEBook();
	void     DrawPageText(HDC hDc);
	void	 Move(int dir,int amount);
	void     GetFontInfo(int &nFontSize,BOOL &bBold,TCHAR* strFontFace,int &nMargin_Width);
	void     SetFontInfo(int nFontSize,BOOL bBold,TCHAR* strFontFace,int nMargin_Width);
	void     GetColorInfo(COLORREF &TextColor,COLORREF& BackGroundColor,COLORREF &SelBackGroundColor);
	void     SetColorInfo(COLORREF TextColor,COLORREF BackGroundColor,COLORREF SelBackGroundColor);
	TCHAR*   GetCurSelText();
	void     AddBookMark();
	void     ButtonDown(POINT pt);
	void     ButtonUp(POINT pt);
	void     MouseMove(POINT pt);
	void     SetFullScreen();
	int      GetListBMCount();
	void     GetBMText(int nIndex,TCHAR* strText,int &nPercent);
	void     GotoPos(int nIndex);
	void     DelBookMark(int nIndex);
	void     SetPercent(int p);
	int      GetPercent();
	void     EBookDone();

private:
	INITEBOOK		pfInitEBook;
	OPENEBOOK		pfOpenEBook;
	GETLASTEBOOK	pfGetLastEBook;
	DRAWPAGETEXT	pfDrawPageText;
	MOVE			pfMove;
	GETFONTINFO		pfGetFontInfo;
	SETFONTINFO		pfSetFontInfo;
	SETCOLORINFO	pfSetColorInfo;
	GETCOLORINFO	pfGetColorInfo;
	GETCURSELTEXT	pfGetCurselText;
	ADDBOOKMARK		pfAddBookMark;
	BUTTONDOWN		pfButtonDown;
	BUTTONUP		pfButtonUp;
	MOUSEMOVE		pfMouseMove;
	SETFULLSCREEN	pfSetFullScreen;
	GETLISTBMCOUNT	pfGetListBMCount;
	GETBMTEXT		pfGetBMText;
	GOTOPOS			pfGotopos;
	DELBOOKMARK		pfDelBookMark;
	SETPERCENT		pfSetPercent;
	GETPERCENT     pfGetPercent;
	EBOOKDONE      pfEBookDone;

private:
	HINSTANCE      m_hDLL;
};
